home *** CD-ROM | disk | FTP | other *** search
- /*
- sc_st_misc.c - general routines for the status window
- */
-
- #include "sc.h"
- #include "sc_count_window.h"
- #include "sc_event.h"
- #include "sc_seer_globals.h"
- #include "sc_filter.h"
-
- #define inQ_x 4
- #define inQ_y 10
- #define inQ "\pin Q:"
-
- void st_update(void);
- void st_update()
- {draw_paks_in_Q();
- }
-
- void st_activate(void);
- void st_activate()
- {
- }
-
- void st_deactivate(void);
- void st_deactivate()
- {
- }
- void st_mouse_down(EventRecord *);
- void st_mouse_down(a_event)
- EventRecord *a_event;
- {
- }
- void st_grow(Point);
- void st_grow(where)
- Point where;
- {
- }
-
-
- void st_new_windef()
- {
- if(gl.wdf_status!=NIL) { /*already have a status window?*/
- /*yes, we can only have one, make sure it is visible*/
- if(&gl.wdf_status->windat.port!=FrontWindow()) /*is status window frontmost?*/
- SelectWindow(gl.wdf_status); /*no, bring it to the front*/
- return;
- }
-
- if(new_windef(WD_status)) { /*if we can make a window*/
- if(sizeof(status_windef)>PRIVATE_SIZE)
- bomb(BOMB_noctl,BMB_no_os,(long)0); /* fix this bomb */
- /*initilize the new display windef*/
- gl.wdf_status=gl.cur_windef;
- gl.cur_windef->w_draw=st_update;
- gl.cur_windef->w_mouse_down=st_mouse_down;
- gl.cur_windef->w_activate=st_activate;
- gl.cur_windef->w_deactavate=st_deactivate;
- gl.cur_windef->w_grow=st_grow;
- STW_wdf->last_paks_in_Q = -1; /*force an update, can't match this*/
- STW_wdf->inq_rect=CUR_WINDOW->portRect;
- STW_wdf->inq_rect.bottom=10;
- }
- }
-
- void print_cntr(int,int);
- void print_cntr(a_tab,a_cnt)
- int a_tab,a_cnt;
- {uint16 cnt_nam;
- cnt_nam=my_filter.counts[a_tab].acnt_tab[a_cnt].filname;
- if(cnt_nam==0) {
- DrawString(RES_pstr(my_filter.counts[a_tab].tab_nam));
- DrawString("\p/");
- DrawNum((long)a_cnt);
- }
- else
- DrawString(RES_pstr(cnt_nam));
- }
-
- /*see if there are a different number of packets in the queue since*/
- /*the last time we checked*/
- void check_paks_in_Q()
- {GrafPtr save_port;
- if(gl.wdf_status==NIL) /*is there a status window?*/
- return; /*no, so no need to update it*/
- /*if there is nothing new in the queue, then no need to update the display*/
- if(STW_wdf->last_paks_in_Q==sp_status->h_inuse)
- return;
-
- /*request an update of the region status region*/
- GetPort(&save_port); /*save the old graf port*/
- SetPort(&gl.wdf_status->windat); /*switch to the port to update*/
- InvalRect(&STW_wdf->inq_rect);
- SetPort(save_port);
- }
-
- /*
- handle an update event for the status window
- GrafPtr set to the window to update
- */
- void draw_paks_in_Q()
- {register int i;
- STW_wdf->last_paks_in_Q = sp_status->h_inuse; /*update the last set we have seen*/
- MoveTo(inQ_x,inQ_y);
- DrawString(inQ);
- DrawNum((long)STW_wdf->last_paks_in_Q);
- DrawChar('/');
- DrawNum(sp_status->d_inuse);
- for(i=0;i<=PE_max;i++) {
- DrawString("\p ");
- DrawString(RES_pstr(my_filter.counts[err_tbi].acnt_tab[i].filname));
- DrawString("\p:");
- DrawNum(my_filter.counts[err_tbi].acnt_tab[i].count);}
-
- MoveTo(4,25);
- DrawString(
- "\pSeer v2.0/public domain/under construction/from Carnegie Mellon University");
- MoveTo(4,40);
- DrawString("\pCenter for Art & Technology/by Aaron Wohl/work:(412)-268-3454/home:(412)-7316159");
- #ifdef xxxyyy
- for(i=0;i<256;i++) {
- if(my_filter.counts[lap_ty_tbi].acnt_tab[i].count==0)
- continue;
- DrawString("\p ");
- print_cntr(lap_ty_tbi,i);
- DrawString("\p:");
- DrawNum(my_filter.counts[lap_ty_tbi].acnt_tab[i].count);
- }
- #endif
- }
-